home *** CD-ROM | disk | FTP | other *** search
/ Internet E-Mail Workshop / Internet E-Mail Workshop.iso / info / uucpfaq. < prev    next >
Text File  |  1993-11-24  |  36KB  |  775 lines

  1.  
  2. Here is a FAQ posting that I have worked up.  It is intended to answer
  3. most questions about how UUCP works, what the UUCP protocols are,
  4. etc., in nauseating detail.  It does not answer such useful questions
  5. as how to configure UUCP, how to make an X.25 PAD not trap ^P, etc.,
  6. and other questions for which I am not necessarily qualified to
  7. provide answers.  Let this posting serve as a challenge to other
  8. people to produce more FAQ answers, which can either be folded into
  9. this posting, or, more likely, form a separate posting.
  10.  
  11. This is the first trial of this posting.  I'll consider any comments,
  12. make a relatively final version, and start posting it every month.
  13. Enjoy!
  14.  
  15. Frequently Asked Questions about UUCP internals
  16. Last updated 1992-02-25
  17.  
  18. This article was written by Ian Lance Taylor <ian@airs.com> and I may
  19. even update it periodically.  Send me mail about suggestions or
  20. inaccuracies.
  21.  
  22. This article describes how the various UUCP protocols work.  It does
  23. not describe how to configure UUCP, nor how to solve UUCP problems,
  24. nor how to deal with UUCP mail.  There are currently no FAQ postings
  25. on any of these topics, and I do not plan to write any.
  26.  
  27. If you haven't read the news.announce.newusers articles, read them.
  28.  
  29. I took a lot of the information from Jamie E. Hanrahan's paper in the
  30. Fall 1990 DECUS Symposium, and from Managing UUCP and Usenet by Tim
  31. O'Reilly and Grace Todino (with contributions by several other
  32. people).  The latter includes most of the former, and is published by
  33.         O'Reilly & Associates, Inc.
  34.         632 Petaluma Avenua
  35.         Sebastopol, CA 95472
  36. It is currently in its tenth edition.  The ISBN number is
  37. 0-937175-48-X.
  38.  
  39. Some information is originally due to a Usenet article by Chuck
  40. Wegrzyn.  The information on the 'g' protocol comes partially from a
  41. paper by G.L. Chesson of Bell Laboratories, partially from Jamie E.
  42. Hanrahan's paper, and partially from source code by John Gilmore.  The
  43. information on the 'f' protocol comes from the source code by Piet
  44. Berteema.  The information on the 't' protocol comes from the source
  45. code by Rick Adams.  The information on the 'e' protocol comes from a
  46. Usenet article by Matthias Urlichs.
  47.  
  48. This article answers the following questions.  If one of these
  49. questions is posted to comp.mail.uucp, you are encouraged to send mail
  50. to the poster referring her or him to this FAQ.  There is no reason to
  51. post a followup, as most of us know the answer already.
  52.  
  53. *) What is the UUCP protocol?
  54. *) What is the 'g' protocol?
  55. *) What is the 'f' protocol?
  56. *) What is the 't' protocol?
  57. *) What is the 'e' protocol?
  58. *) What is the 'x' protocol?
  59.  
  60. *) What is the UUCP protocol?
  61.  
  62. The UUCP protocol is a conversation between two UUCP packages.  A UUCP
  63. conversation consists of three parts: an initial handshake, a series
  64. of file transfer requests, and a final handshake.
  65.  
  66. Before the initial handshake, the caller will usually have logged in
  67. the called machine and somehow started the UUCP package there.  On
  68. Unix this is normally done by setting the shell of the login name used
  69. to /usr/lib/uucp/uucico.
  70.  
  71. All messages in the initial handshake begin with a ^P (a byte with the
  72. octal value \020) and end with a null byte (\000).
  73.  
  74. The initial handshake goes as follows.  It is begun by the called
  75. machine.
  76.  
  77. called: \020Shere=hostname\000
  78.     The hostname is the UUCP name of the called machine.  Older UUCP
  79.     packages do not output it, and simply send \020Shere\000.
  80.  
  81. caller: \020Shostname options\000
  82.     The hostname is the UUCP name of the calling machine.  The
  83.     following options may appear (or there may be none):
  84.         -QSEQ
  85.             Report sequence number for this conversation.  The
  86.             sequence number is stored at both sites, and incremented
  87.             after each call.  If there is a sequence number mismatch,
  88.             something has gone wrong (somebody may have broken
  89.             security by pretending to be one of the machines) and the
  90.             call is denied.
  91.         -xLEVEL
  92.             Requests the called system to set its debugging level to
  93.             the specified value.  This is not supported by all
  94.             systems.
  95.         -pGRADE
  96.         -vgrade=GRADE
  97.             Requests the called system to only transfer files of the
  98.             specified grade or higher.  This is not supported by all
  99.             systems.  Some systems support -p, some support -vgrade=.
  100.         -R
  101.             Indicates that the calling UUCP understands how to restart
  102.             failed file transmissions.  Supported only by System V
  103.             Release 4 UUCP.
  104.         -ULIMIT
  105.             Reports the ulimit value of the calling UUCP.  The limit
  106.             is specified as a base 16 number in C notation (e.g.
  107.             -U0x1000000).  This number is the number of 512 byte
  108.             blocks in the largest file which the calling UUCP can
  109.             create.  The called UUCP may not transfer a file larger
  110.             than this.  Supported only by System V Release 4 UUCP.
  111.         -N
  112.             Indicates that the calling UUCP understands the Taylor
  113.             UUCP size limiting extensions.  Supported only by Taylor
  114.             UUCP.
  115.  
  116. called: \020ROK\000
  117.     There are actually several possible responses.
  118.         ROK
  119.             The calling UUCP is acceptable, and the handshake proceeds
  120.             to the protocol negotiation.  Some options may also
  121.             appear; see below.
  122.         ROKN
  123.             The calling UUCP is acceptable, it specified -N, and the
  124.             called UUCP understands the Taylor UUCP size limiting
  125.             extensions.  Supported only by Taylor UUCP.
  126.         RLCK
  127.             The called UUCP already has a lock for the calling UUCP,
  128.             which normally indicates the two machines are already
  129.             communicating.
  130.         RCB
  131.             The called UUCP will call back.  This may be used to avoid
  132.             impostors (but only one machine out of each pair should
  133.             call back, or no conversation will ever begin).
  134.         RBADSEQ
  135.             The call sequence number is wrong (see the -Q discussion
  136.             above).
  137.         RLOGIN
  138.             The calling UUCP is using the wrong login name.
  139.         RYou are unknown to me
  140.             The calling UUCP is not known to the called UUCP, and the
  141.             called UUCP does not permit connections from unknown
  142.             systems.
  143.     If the response is ROK, the following options are supported by
  144.     System V Release 4 UUCP.
  145.         -R
  146.             The called UUCP knows how to restart failed file
  147.             transmissions.
  148.         -ULIMIT
  149.             Reports the ulimit value of the called UUCP.  The limit is
  150.             specified as a base 16 number in C notation.  This number
  151.             is the number of 512 byte blocks in the largest file which
  152.             the called UUCP can create.  The calling UUCP may not send
  153.             a file larger than this.
  154.         -xLEVEL
  155.             I'm not sure about this one.  It may request the calling
  156.             UUCP to set its debugging level to the specified value.
  157.     If the response is not ROK (or ROKN) both sides hang up the phone,
  158.     abandoning the call.
  159.  
  160. called: \020Pprotocols\000
  161.     Note that the called UUCP outputs two strings in a row.  The
  162.     protocols string is a list of UUCP protocols supported by the
  163.     caller.  Each UUCP protocol has a single character name.  These
  164.     protocols are discussed in more detail later in this document.
  165.     For example, the called UUCP might send \020Pgf\000.
  166.  
  167. caller: \020Uprotocol\000
  168.     The calling UUCP selects which protocol to use out of the
  169.     protocols offered by the called UUCP.  If there are no mutually
  170.     supported protocols, the calling UUCP sends \020UN\000 and both
  171.     sides hang up the phone.  Otherwise the calling UUCP sends
  172.     something like \020Ug\000.
  173.  
  174. At this point the initial handshake has been completed, and both sides
  175. turn on the selected protocol.  For some protocols (notably 'g') a
  176. further handshake is done at this point.
  177.  
  178. Each protocol supports a method for sending a command to the remote
  179. system.  This method is used to transmit a series of commands between
  180. the two UUCP packages.  At all times, one package is the master and
  181. the other is the slave.  Initially, the calling UUCP is the master.
  182.  
  183. If a protocol error occurs during the exchange of commands, both sides
  184. move immediately to the final handshake.
  185.  
  186. The master will send one of four commands: S, R, X or H.
  187.  
  188. Any file name referred to below is either an absolute pathname
  189. beginning with "/", a public directory pathname beginning with "~/", a
  190. pathname relative to a user's home directory beginning with "~USER/",
  191. or a spool directory file name.  File names in the spool directory are
  192. not pathnames, but instead are converted to pathnames within the spool
  193. directory by UUCP.  They always begin with "C." (for a command file
  194. created by uucp or uux), "D." (for a data file created by uucp, uux or
  195. by an execution, or received from another system for an execution), or
  196. "X." (for an execution file created by uux or received from another
  197. system).
  198.  
  199. master: S FROM TO USER -OPTIONS TEMP MODE NOTIFY SIZE
  200.     The S and the - are literal characters.  This is a request by the
  201.     master to send a file to the slave.
  202.         FROM
  203.             The name of the file to send.  If the C option does not
  204.             appear in OPTIONS, the master will actually open and send
  205.             this file.  Otherwise the file has been copied to the
  206.             spool directory, where it is named TEMP.  The slave
  207.             ignores this field unless TO is a directory, in which case
  208.             the basename of FROM will be used as the file name.  If
  209.             FROM is a spool directory filename, it must be a data file
  210.             created for or by an execution, and must begin with "D.".
  211.         TO
  212.             The name to give the file on the slave.  If this field
  213.             names a directory (a name ending in '/' is taken to name a
  214.             directory even if one does not already exist with that
  215.             name) the file is placed within that directory with the
  216.             basename of FROM.  If TO begins with "X.", an execution
  217.             file will be created on the slave.  Otherwise, if TO
  218.             begins with "D." it names a data file to be used by some
  219.             execution file.  Otherwise, TO may not be in the spool
  220.             directory.
  221.         USER
  222.             The name of the user who requested the transfer.
  223.         OPTIONS
  224.             A list of options to control the transfer.  The following
  225.             options are defined (all options are single characters):
  226.                 C
  227.                     The file has been copied to the spool directory
  228.                     (the master should use TEMP rather than FROM).
  229.                 c
  230.                     The file has not been copied to the spool
  231.                     directory (this is the default).
  232.                 d
  233.                     The slave should create directories as necessary
  234.                     (this is the default).
  235.                 f
  236.                     The slave should not create directories if
  237.                     necessary, but should fail the transfer instead.
  238.                 m
  239.                     The master should send mail to USER when the
  240.                     transfer is complete.
  241.                 n
  242.                     The slave should send mail to NOTIFY when the
  243.                     transfer is complete.
  244.         TEMP
  245.             If the C option appears in OPTIONS, this names the file to
  246.             be sent.  Otherwise if FROM is in the spool directory,
  247.             TEMP is the same as FROM.  Otherwise TEMP is a dummy
  248.             string, normally "D.0".  After the transfer has been
  249.             succesfully completed, the master will delete the file
  250.             TEMP.
  251.         MODE
  252.             This is an octal number giving the mode of the file on
  253.             MASTER.  If the file is not in the spool directory, the
  254.             slave will always create it with mode 0666, except that if
  255.             (MODE & 0111) is not zero (the file is executable), the
  256.             slave will create the file with mode 0777.  If the file is
  257.             in the spool directory, some UUCP packages will use the
  258.             algorithm above and some will always create the file with
  259.             mode 0600.
  260.         NOTIFY
  261.             This field is only present if the n option appears in
  262.             OPTIONS.  When the transfer is successfully completed, the
  263.             slave will send mail to NOTIFY, which must be a legal
  264.             mailing address on the slave.  If a SIZE field will appear
  265.             but the n option does not appear, NOTIFY will be the
  266.             string "dummy" or simply a pair of double quotes.
  267.         SIZE
  268.             This field is only present when doing size negotiation,
  269.             either with Taylor UUCP or SVR4 UUCP.  It is the size of
  270.             the file in bytes.  SVR4 UUCP sends the size in base 16 as
  271.             0x.... while Taylor UUCP sends the size as a decimal
  272.             integer.
  273.  
  274.     The slave then responds with an S command response.
  275.         SY START
  276.             The slave is willing to accept the file, and file transfer
  277.             begins.  The START field will only be present when using
  278.             SVR4 file restart.  It specifies the byte offset into the
  279.             file at which to start sending.  If this is a new file,
  280.             START will be 0x0.
  281.         SN2
  282.             The slave denies permission to transfer the file.  This
  283.             can mean that the destination directory may not be
  284.             accessed, or that no requests are permitted.  It implies
  285.             that the file transfer will never succeed.
  286.         SN4
  287.             The slave is unable to create the necessary temporary
  288.             file.  This implies that the file transfer may succeed
  289.             later.
  290.         SN6
  291.             This is only used by Taylor UUCP size negotiation.  It
  292.             means that the slave considers the file too large to
  293.             transfer at the moment, but it may be possible to transfer
  294.             it at some other time.
  295.         SN7
  296.             This is only used by Taylor UUCP size negotiation.  It
  297.             means that the slave considers the file too large to ever
  298.             transfer.
  299.  
  300.     If the slave responds with SY, a file transfer begins.  When the
  301.     file transfer is complete, the slave sends a C command response.
  302.         CY
  303.             The file transfer was successful.
  304.         CN5
  305.             The temporary file could not be moved into the final
  306.             location.  This implies that the file transfer will never
  307.             succeed.
  308.  
  309.     After the C command response has been received (in the SY case) or
  310.     immediately (in an SN case) the master will send another command.
  311.  
  312. master: R FROM TO USER -OPTIONS SIZE
  313.     The R and the - are literal characters.  This is a request by the
  314.     master to receive a file from the slave.  I do not know how SVR4
  315.     UUCP implements file transfer restart in this case.
  316.         FROM
  317.             This is the name of the file on the slave which the master
  318.             wishes to receive.  It must not be in the spool directory,
  319.             and it may not contain any wildcards.
  320.         TO
  321.             This is the name of the file to create on the master.  I
  322.             do not believe that it can be a directory.  It may only be
  323.             in the spool directory if this file is being requested to
  324.             support an execution either on the master or on some
  325.             system other than the slave.
  326.         USER
  327.             The name of the user who requested the transfer.
  328.         OPTIONS
  329.             A list of options to control the transfer.  The following
  330.             options are defined (all options are single characters):
  331.                 d
  332.                     The master should create directories as necessary
  333.                     (this is the default).
  334.                 f
  335.                     The master should not create directories if
  336.                     necessary, but should fail the transfer instead.
  337.                 m
  338.                     The master should send mail to USER when the
  339.                     transfer is complete.
  340.         SIZE
  341.             This only appears if Taylor UUCP size negotiation is being
  342.             used.  It specifies the largest file which the master is
  343.             prepared to accept (when using SVR4 UUCP, this was
  344.             specified in the -U option during the initial handshake).
  345.  
  346.     The slave then responds with an R command response.
  347.         RY MODE
  348.             The slave is willing to send the file, and file transfer
  349.             begins.  MODE is the octal mode of the file on the slave.
  350.             The master treats this just as the slave does the MODE
  351.             argument in the send command, q.v.
  352.         RN2
  353.             The slave is not willing to send the file, either because
  354.             it is not permitted or because the file does not exist.
  355.             This implies that the file request will never succeed.
  356.         RN6
  357.             This is only used by Taylor UUCP size negotiation.  It
  358.             means that the file is too large to send, either because
  359.             of the size limit specifies by the master or because the
  360.             slave considers it too large.  The file transfer may
  361.             succeed later, or it may not (this will be cleared up in a
  362.             later release of Taylor UUCP).
  363.  
  364.     If the slave responds with RY, a file transfer begins.  When the
  365.     file transfer is complete, the master sends a C command.  The
  366.     slave pretty much ignores this, although it may log it.
  367.         CY
  368.             The file transfer was successful.
  369.         CN5
  370.             The temporary file could not be moved into the final
  371.             location.
  372.  
  373.     After the C command response has been sent (in the RY case) or
  374.     immediately (in an RN case) the master will send another command.
  375.  
  376. master: X FROM TO USER -OPTIONS
  377.     The X and the - are literal characters.  This is a request by the
  378.     master to, in essence, execute uucp on the slave.  The slave
  379.     should execute "uucp FROM TO".
  380.         FROM
  381.             This is the name of the file or files on the slave which
  382.             the master wishes to transfer.  It will often contain
  383.             wildcard characters, since otherwise an R command will
  384.             normally suffice (however, this command can also be used
  385.             to request the transfer of a file on the slave to a third
  386.             system).  Any wildcards should be expanded on the slave.
  387.         TO
  388.             This is the name of the file or directory to which the
  389.             files should be transferred.  This will normally use a
  390.             UUCP name.  For example, if the master wishes to receive
  391.             the files itself, it would use "master!path".
  392.         USER
  393.             The name of the user who requested the transfer.
  394.         OPTIONS
  395.             A list of options to control the transfer.  It is not
  396.             clear which, if any, options are supported by most UUCP
  397.             packages.
  398.  
  399.     The slave then responds with an X command response.
  400.         XY
  401.             The request was accepted, and the appropriate file
  402.             transfer commands have been queued up for later
  403.             processing.
  404.         XN
  405.             The request was denied.  No particular reason is given.
  406.  
  407.     In either case, the master will then send another command.
  408.  
  409. master: H
  410.     This is used by the master to hang up the connection.  The slave
  411.     will respond with an H command response.
  412.         HY
  413.             The slave agrees to hang up the connection.  In this case
  414.             the master sends another HY command.  In some UUCP
  415.             packages the slave will then send a third HY command.  At
  416.             this point the protocol is shut down, and the final
  417.             handshake is begun.
  418.         HN
  419.             The slave does not agree to hang up.  In this case the
  420.             master and the slave exchange roles.  The next command
  421.             will be sent by the former slave, which is the new master.
  422.             The roles may be reversed several times during a single
  423.             connection.
  424.  
  425. After the protocol has been shut down, the final handshake is
  426. performed.  This handshake has no real purpose, and some UUCP packages
  427. simply drop the connection rather than do it (in fact, some will drop
  428. the connection immediately after both sides agree to hangup, without
  429. even closing down the protocl).
  430.  
  431. caller: \020OOOOOO\000
  432. called: \020OOOOOOO\000
  433.  
  434. That is, the calling UUCP sends six O's and the called UUCP replies
  435. with seven O's.  Some UUCP packages always send six O's.
  436.  
  437. *) What is the 'g' protocol?
  438.  
  439. The 'g' protocol is a packet based flow controlled error correcting
  440. protocol that requires an eight bit clear connection.  It is the
  441. original UUCP protocol, and is supported by all UUCP implementations.
  442. Many implementations of it are only able to support small window and
  443. packet sizes, specifically a window size of 3 and a packet size of 64
  444. bytes, but the protocol itself can support up to a window size of 7
  445. and a packet size of 4096 bytes.  Complaints about the inefficiency of
  446. the 'g' protocol generally refer to specific implementations, rather
  447. than the correctly implemented protocol.
  448.  
  449. The 'g' protocol was originally designed for general packet drivers,
  450. and thus contains some features that are not used by UUCP, including
  451. an alternate data channel and the ability to renegotiate packet and
  452. window sizes during the communication session.
  453.  
  454. The 'g' protocol is spoofed by many Telebit modems.  When spoofing is
  455. in effect, each Telebit modem uses the 'g' protocol to communicate
  456. with the attached computer, but the data between the modems is sent
  457. using a Telebit proprietary error correcting protocol.  This allows
  458. for very high throughput over the Telebit connection, which, because
  459. it is half-duplex, would not normally be able to handle the 'g'
  460. protocol very well at all.
  461.  
  462. This discussion of the 'g' protocol explains how it works, but does
  463. not discuss useful error handling techniques.  Some discussion of this
  464. can be found in Jamie E. Hanrahan's paper, cited above.
  465.  
  466. All 'g' protocol communication is done with packets.  Each packet
  467. begins with a six byte header.  Control packets consist only of the
  468. header.  Data packets contain additional data.
  469.  
  470. The header is as follows:
  471.  
  472.     \020
  473.         Every packet begins with a ^P.
  474.     k (1 <= k <= 9)
  475.         The k value is always 9 for a control packet.  For a data
  476.         packet, the k value indicates how must data follows the six
  477.         byte header.  The amount of data is 2 ** (k + 4), where **
  478.         indicates exponentiation.  Thus a k value of 1 means 32 data
  479.         bytes and a k value of 8 means 4096 data bytes.  The k value
  480.         for a data packet must be between 1 and 8 inclusive.
  481.     checksum low byte
  482.     checksum high byte
  483.         The checksum value is described below.
  484.     control byte
  485.         The control packet indicates the type of packet, and is
  486.         described below.
  487.     xor byte
  488.         This byte is the xor of k, the checksum low byte, the checksum
  489.         high byte and the control byte (i.e. the second, third, fourth
  490.         and fifth header bytes).  It is used to ensure that the header
  491.         data is valid.
  492.  
  493. The control byte in the header is composed of three bit fields,
  494. referred to here as TT (two bits), XXX (three bits) and YYY (three
  495. bits).  The control is TTXXXYYY, or (TT << 6) + (XXX << 3) + YYY.
  496.  
  497. The TT field takes on the following values:
  498.     0
  499.         This is a control packet.  In this case the k byte in the
  500.         header must be 9.  The XXX field indicates the type of control
  501.         packet; these types are described below.
  502.     1
  503.         This is an alternate data channel packet.  This is not used by
  504.         UUCP.
  505.     2
  506.         This is a data packet, and the entire contents of the attached
  507.         data field (whose length is given by the k byte in the header)
  508.         are valid.  The XXX and YYY fields are described below.
  509.     3
  510.         This is a short data packet.  Let the length of the data field
  511.         (as given by the k byte in the header) be L.  Let the first
  512.         byte in the data field be B1.  If B1 is less than 128 (if the
  513.         most significant bit of B1 is 0), then there are L - B1 valid
  514.         bytes of data in the data field, beginning with the second
  515.         byte.  If B1 >= 128, let B2 be the second byte in the data
  516.         field.  Then there are L - ((B1 & 0x7f) + (B2 << 7)) valid
  517.         bytes of data in the data field, beginning with the third
  518.         byte.  In all cases L bytes of data are sent (and all data
  519.         bytes participate in the checksum calculation) but some of the
  520.         trailing bytes may be dropped by the receiver.   The XXX and
  521.         YYY fields are described below.
  522.  
  523. In a data packet (short or not) the XXX field gives the sequence
  524. number of the packet.  Thus sequence numbers can range from 0 to 7,
  525. inclusive.  The YYY field gives the sequence number of the last
  526. correctly received packet.
  527.  
  528. Each communication direction uses a window which indicates how many
  529. unacknowledged packets may be transmitted before waiting for an
  530. acknowledgement (the window may be different in each direction).  The
  531. window may range from 1 to 7. For example, if the window is 3 and the
  532. last packet acknowledged was packet number 6, packet numbers 7, 0 and
  533. 1 may be sent but the sender must wait for an acknowledgement before
  534. sending packet number 2.  This acknowledgement could come as the YYY
  535. field of a data packet or as the YYY field of a RJ or RR control
  536. packet (described below).
  537.  
  538. Each packet must be transmitted in order (the sender may not skip
  539. sequence numbers).  Each packet must be acknowledged, and each packet
  540. must be acknowledged in order.
  541.  
  542. In a control packet, the XXX field takes on the following values:
  543.     1 CLOSE
  544.         The connection should be closed immediately.  This is
  545.         typically sent when one side has seen too many errors and
  546.         wants to give up.  It is also sent when shutting down the
  547.         protocol.  If an unexpected CLOSE packet is received, a CLOSE
  548.         packet should be sent and the 'g' protocol should halt,
  549.         causing UUCP to enter the final handshake.
  550.     2 RJ or NAK
  551.         The last packet was not received correctly.  The YYY field
  552.         contains the sequence number of the last correctly received
  553.         packet.
  554.     3 SRJ
  555.         Selective reject.  The YYY field contains the sequence number
  556.         of a packet that was not received correctly, and should be
  557.         retransmitted.  This is not used by UUCP, and most
  558.         implementations will not recognize it.
  559.     4 RR or ACK
  560.         Packet acknowledgement.  The YYY field contains the sequence
  561.         number of the last correctly received packet.
  562.     5 INITC
  563.         Third initialization packet.  The YYY field contains the
  564.         maximum window size to use.
  565.     6 INITB
  566.         Second initialization packet.  The YYY field contains the
  567.         packet size to use.  It requests a size of 2 ** (YYY + 5);
  568.         note that this is not the same coding used for the k byte in
  569.         the packet header (it is 1 less).  Some UUCP implementations
  570.         can handle any packet size up to that specified; some can only
  571.         handled exactly the size specified.
  572.     7 INITA
  573.         First initialization packet.  The YYY field contains the
  574.         maximum window size to use.
  575.  
  576. The checksum of a control packet is simply 0xaaaa - the control byte.
  577.  
  578. The checksum of a data packet is 0xaaaa - (CHECK ^ the control byte),
  579. where ^ denotes exclusive or, and CHECK is the result of the following
  580. routine as run on the contents of the data field (every byte in the
  581. data field participates in the checksum, even for a short data
  582. packet).  This is the routine used by Taylor UUCP, and is a slightly
  583. modified version of a routine which John Gilmore patched from G.L.
  584. Chesson's original paper.  The z argument points to the data and the c
  585. argument indicates how much data there is.
  586.  
  587. int
  588. igchecksum (z, c)
  589.      register const char *z;
  590.      register int c;
  591. {
  592.   register unsigned int ichk1, ichk2;
  593.  
  594.   ichk1 = 0xffff;
  595.   ichk2 = 0;
  596.  
  597.   do
  598.     {
  599.       register unsigned int b;
  600.  
  601.       /* Rotate ichk1 left.  */
  602.       if ((ichk1 & 0x8000) == 0)
  603.         ichk1 <<= 1;
  604.       else
  605.         {
  606.           ichk1 <<= 1;
  607.           ++ichk1;
  608.         }
  609.  
  610.       /* Add the next character to ichk1.  */
  611.       b = *z++ & 0xff;
  612.       ichk1 += b;
  613.  
  614.       /* Add ichk1 xor the character position in the buffer counting from
  615.          the back to ichk2.  */
  616.       ichk2 += ichk1 ^ c;
  617.  
  618.       /* If the character was zero, or adding it to ichk1 caused an
  619.          overflow, xor ichk2 to ichk1.  */
  620.       if (b == 0 || (ichk1 & 0xffff) < b)
  621.         ichk1 ^= ichk2;
  622.     }
  623.   while (--c > 0);
  624.  
  625.   return ichk1 & 0xffff;
  626. }
  627.  
  628. When the 'g' protocol is started, the calling UUCP sends an INITA
  629. control packet with the window size it wishes the called UUCP to use.
  630. The called UUCP responds with an INITA packet with the window size it
  631. wishes the calling UUCP to use.  Pairs of INITB and INITC packets are
  632. then similarly exchanged.  When these exchanges are completed, the
  633. protocol is considered to have been started.
  634.  
  635. When a UUCP package transmits a command, it sends one or more data
  636. packets.  All the data packets will normally be complete, although
  637. some UUCP packages may send a the last one as a short packet.  The
  638. UUCP package receiving the command will know when the command has
  639. finished because it will be terminated by a null byte sent as data.
  640. Some UUCP packages require the last byte of the last packet sent to be
  641. null, even if the command ends earlier in the packet.  Some packages
  642. may require all the trailing bytes in the last packet to be null, but
  643. I have not confirmed this.
  644.  
  645. When a UUCP package sends a file, it will send a sequence of data
  646. packets.  The end of the file is signalled by a short data packet
  647. containing zero valid bytes (it will normally be preceeded by a short
  648. data packet containing the last few bytes in the file).
  649.  
  650. Note that the sequence numbers cover the entire communication session,
  651. including both command and file data.
  652.  
  653. When the protocol is shut down, each UUCP package sends a CLOSE
  654. control packet.
  655.  
  656. *) What is the 'f' protocol?
  657.  
  658. The 'f' protocol is a seven bit protocol which checksums an entire
  659. file at a time.  It only uses the characters between \040 and \176
  660. (ASCII space and ~) inclusive as well as the carriage return
  661. character.  It can be very efficient for transferring text only data,
  662. but it is very inefficient at transferring eight bit data (such as
  663. compressed news).  It is not flow controlled, and the checksum is
  664. fairly insecure over large files, so using it over a serial connection
  665. requires handshaking (XON/XOFF can be used) and error correcting
  666. modems.  Some people think it should not be used even under those
  667. circumstances.
  668.  
  669. I believe the 'f' protocol originated in BSD versions of UUCP.  It was
  670. originally intended for transmission over X.25 PAD links.
  671.  
  672. The 'f' protocol has no startup or finish protocol.  However, both
  673. sides should sleep for a couple of seconds before starting up, because
  674. typically they will switch the terminal into XON/XOFF mode and want to
  675. allow the changes to settle before beginning transmission.
  676.  
  677. When a UUCP package transmits a command, it simply sends a string
  678. terminated by a carriage return.
  679.  
  680. When a UUCP package transmits a file, each byte b of the file is
  681. translated according to the following table:
  682.  
  683.        0 <= b <=  037: 0172, b + 0100 (0100 to 0137)
  684.      040 <= b <= 0171:       b        ( 040 to 0171)
  685.     0172 <= b <= 0177: 0173, b - 0100 ( 072 to  077)
  686.     0200 <= b <= 0237: 0174, b - 0100 (0100 to 0137)
  687.     0240 <= b <= 0371: 0175, b - 0200 ( 040 to 0171)
  688.     0372 <= b <= 0377: 0176, b - 0300 ( 072 to  077)
  689.  
  690. That is, a byte between \040 and \171 inclusive is transmitted as is,
  691. and all other bytes are prefixed and modified as shown.
  692.  
  693. When all the file data is sent, a seven byte sequence is sent: two
  694. bytes of \176 followed by four ASCII bytes of the checksum as printed
  695. in base 16 followed by a carriage return.  For example, if the
  696. checksum was 0x1234, this would be sent: "\176\1761234\r".
  697.  
  698. The checksum is initialized to 0xffff.  For each byte that is sent it
  699. is modified as follows (where b is the byte before it has been
  700. transformed as described above):
  701.  
  702.       /* Rotate the checksum left.  */
  703.       if ((ichk & 0x8000) == 0)
  704.         ichk <<= 1;
  705.       else
  706.         {
  707.           ichk <<= 1;
  708.           ++ichk;
  709.         }
  710.  
  711.       /* Add the next byte into the checksum.  */
  712.       ichk += b;
  713.  
  714. When the receiving UUCP sees the checksum, it compares it against its
  715. own calculated checksum and replies with a single character followed
  716. by a carriage return.
  717.     G
  718.         The file was received correctly.
  719.     R
  720.         The checksum did not match, and the file should be resent from
  721.         the beginning.
  722.     Q
  723.         The checksum did not match, but too many retries have occurred
  724.         and the communication session should be abandoned.
  725.  
  726. The sending UUCP checks the returned character and acts accordingly.
  727.  
  728. *) What is the 't' protocol?
  729.  
  730. The 't' protocol is intended for TCP links.  It does no error checking
  731. or flow control, and requires an eight bit clear channel.
  732.  
  733. I believe the 't' protocol originated in BSD versions of UUCP.
  734.  
  735. When a UUCP package transmits a command, it first gets the length of
  736. the command string, C.  It then sends ((C / 512) + 1) * 512 bytes (the
  737. smallest multiple of 512 which can hold C bytes plus a null byte)
  738. consisting of the command string itself followed by trailing null
  739. bytes.
  740.  
  741. When a UUCP package sends a file, it sends it in blocks.  Each block
  742. contains at most 1024 bytes of data.  Each block consists of four
  743. bytes containing the amount of data in binary (most significant byte
  744. first, the same format as used by the Unix function htonl) followed by
  745. that amount of data.  The end of the file is signalled by a block
  746. containing zero bytes of data.
  747.  
  748. *) What is the 'e' protocol?
  749.  
  750. The 'e' protocol is similar to the 't' protocol.  It does no flow
  751. control or error checking and is intended for use over TCP.
  752.  
  753. The 'e' protocol originated in versions of HDB UUCP.
  754.  
  755. When a UUCP package transmits a command, it simply sends the command
  756. as an ASCII string terminated by a null byte.
  757.  
  758. When a UUCP package transmits a file, it sends the complete size of
  759. the file as an ASCII decimal number.  The ASCII string is padded out
  760. to 20 bytes with null bytes (i.e. if the file is 1000 bytes long, it
  761. sends "1000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0").  It then sends the
  762. entire file.
  763.  
  764. *) What is the 'x' protocol?
  765.  
  766. I believe that the 'x' protocol was intended for use over X.25 virtual
  767. circuits.  It relies on a write of zero bytes being read as zero bytes
  768. without stopping communication.  I have heard that it does not work
  769. correctly.  If someone would care to fill this in more, I would be
  770. grateful.
  771. --
  772. Ian Taylor                  ian@airs.com                  uunet!airs!ian
  773. First person to identify this quote wins a free e-mail message:
  774. ``The will to be stupid is a very powerful force.''
  775.